package zhtt;

import org.apache.ibatis.session.SqlSession;
import org.junit.Test;
import zhtt.demo01.Blog;

/**
 * Created by zhtt on 2017/4/28.
 */
public class DaoTest {

    @Test
    public void get(){
        SqlSession sqlSession=null;
        try{
            sqlSession = SessionFactoryUtil.getSqlSessionIntance();
            Blog blog=sqlSession.selectOne("zhtt.demo01.Blog.get",1);
            System.out.println(blog);
        }catch (Exception e){
            e.printStackTrace();
            sqlSession.rollback();
        }finally {
            if(sqlSession!=null)
                sqlSession.close();
        }
    }

    @Test
    public void get2(){
        SqlSession sqlSession=null;
        try{
            sqlSession = SessionFactoryUtil2.getSqlSessionIntance2();
            Blog blog=sqlSession.selectOne("zhtt.demo01.Blog.get",1);
            System.out.println(blog);
        }catch (Exception e){
            e.printStackTrace();
            sqlSession.rollback();
        }finally {
            if(sqlSession!=null)
                sqlSession.close();
        }
    }

    @Test
    public void get3(){
        SqlSession sqlSession=null;
        try{
            sqlSession = SessionFactoryUtil3.getSqlSessionIntance2();
            Blog blog=sqlSession.selectOne("zhtt.demo01.Blog.get",1);
            System.out.println(blog);
        }catch (Exception e){
            e.printStackTrace();
            sqlSession.rollback();
        }finally {
            if(sqlSession!=null)
                sqlSession.close();
        }
    }
}
